package com.zy.baselib.tools;


import android.content.Context;

import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;

import java.util.Objects;

public class DividerItemUtil {

    /**
     * 为recycleView 提供分割线效果
     * @param orientation 方向
     * @param id 分割线资源id
     * @return 分割线效果
     */
    public static DividerItemDecoration getItemDecoration(Context context, int orientation, @DrawableRes int id) {
        DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, orientation);
        dividerItemDecoration.setDrawable(Objects.requireNonNull(ContextCompat.getDrawable(context, id)));
        return dividerItemDecoration;
    }

    public static DividerItemDecoration getVerticalItemDecoration(Context context, @DrawableRes int id) {
        return getItemDecoration(context, LinearLayoutManager.VERTICAL, id);
    }
}
